<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel='stylesheet' href='../../../public/stylesheets/index.css'/>
</head>
<body>
<section>
    <div class="sectionMain">
        <div class="bgGray">
            <input id="startTime" type="date" value="2015-09-24"/>
            <input id="endTime" type="date" value="2015-09-24"/>
            <label><input id="r1" name="uid" onclick="model.order(['id',this.value])" type="radio" value="ASC" checked/>正序</label>
            <label><input id="r2" name="uid" onclick="model.order(['id',this.value])" type="radio" value="DESC"/>倒叙</label>
            <button onclick="model.screen()">筛选</button>
            <select id="status" onchange="model.screen({status:$('#status').val()})">
                <option value ="all">所有</option>
                <option value ="0">未提交</option>
                <option selected value ="1">审核中</option>
                <option value ="2">审核通过</option>
                <option value ="3">审核未通过</option>
            </select>
        </div>
        <div class="biaomingTable">
            <span id="titleName" class="TableName"></span>
        </div>
        <div class="sectionMainTable"></div>
        <div class="center">
            <ul class="pagination">

            </ul>
        </div>
    </div>
</section>
</body>
<script src="../../js/script_min.js"></script>
<script src="../../js/util.js"></script>
<script src="../../js/sheet.js"></script>
<script src="../../../layui/layui.all.js"></script>

<script>
    class admission_company extends sheet{
        screen(args){
            if(args){
                this.postData = Object.assign(this.postData,args);
            }
            this.postData.screen.startTime= new Date($("#startTime").val()).getTime();
            this.postData.screen.endTime = new Date($("#endTime").val()).getTime();
            this.init(0).then(res=>{this.setTitle()});
        };
        setTitle(){
            $('#titleName').text('单位会员入驻(' + this.storage.count + ')');
        };
    }
    let model = new admission_company({
        api:`backStage-company-member`,
        postData:{
            status:1,
            page:window.sessionStorage.getItem("page")||0,
            limit:20,
            order:JSON.parse(window.sessionStorage.getItem("order"))||["id","ASC"],
            screen:{startTime:0,endTime:new Date().getTime()},
        },
        buttons:[
            {
                title:"审核",
                text:"同意/不同意",
                fn:(len)=>{
                    let status = model.storage.currentData[len].status;
                    if(status != 1){
                        alert(`不能审核`);
                        return ;
                    }
                    layer.confirm('是否同意本次单位会员申请?', {
                        btn: ['同意','不同意'] //按钮
                    }, function(index){
                        let data = {
                            id:model.storage.currentData[len]["id"],
                            result:`同意`,
                            suggestMsg:`同意`
                        };
                        console.log(data);
                        layer.close(index);
                        ServerAgent.invoke("backStage-company-member-examine",data).then(res=>{
                            alert(`${res.args.message}`);
                            model.init().then(res=>{model.setTitle();});
                        })
                    }, function(index){
                        let str=prompt("请填写不同意的理由","资料不齐全");
                        layer.close(index);
                        if(str===null)return;
                        let data = {
                            id:model.storage.currentData[len]["id"],
                            result:false,
                            suggestMsg:str,
                        };
                        console.log(data);
                        ServerAgent.invoke("backStage-company-member-examine",data).then(res=>{
                            alert(`${res.args.message}`);
                            model.init().then(res=>{model.setTitle();});
                        })
                    });
                },
            }
        ],
    });
    model.init().then(res=>{model.setTitle();});
    $("#endTime").val(model.getEndTime());
</script>
</html>